package com.yueke.gemini.file;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

/**
 * 读取文件工具类
 * Created by admin on 2017/10/22.
 */
public class ReadFileByLines {

    /**
     * 将文件转换成字符流
     * @param fileName
     * @return
     */
    public static String readFileByLine(String fileName){
        //1.创建文件对象
        String reslut="";
        File file =new File(fileName);
        int line_number=0;
        //2.创建buffferreader对象读取文件
        try {
            BufferedReader reader =new BufferedReader(new FileReader(file));
            String temp="";
            while ((temp=reader.readLine())!=null) {
                reslut =reslut +(line_number++)+":"+temp+"\n";


            }

            reader.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return reslut;
    }
}
